package com.rfsp.common.service;

import com.rfsp.common.cache.ParamCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.rfsp.common.base.BaseService;
import com.rfsp.common.mapper.ParamMapper;
import com.rfsp.common.pojo.po.ParamPO;

@Service
public class ParamService extends BaseService<ParamPO> {

	public Logger log = LoggerFactory.getLogger(ParamService.class);
	
	@Autowired
	ParamMapper paramMapper;

	@Value("${spring.profiles.active}")
	String dev;


	public String getValue(String key){
		return paramMapper.getValue(key);
	}

	public String getCacheValue(String key){
		String v = ParamCache.get(key);
		if(v == null){
			v = getValue(key);
			ParamCache.put(key, v);
		}
		return v;
	}

	public boolean isDev(){
		return "dev".equals(dev);
	}

	public boolean isSit(){
		return "1".equals(getCacheValue(ParamCache.ENV));
	}

	public boolean isProd(){
		return !isSit();
	}
}
